package com.example.myproject.dto;

public class CommonResponse<T> {
    private String status;
    private T data;
    private String message; // 添加消息字段

    public CommonResponse() {}

    public CommonResponse(String status, T data) {
        this.status = status;
        this.data = data;
    }

    public CommonResponse(String status, String message) {
        this.status = status;
        this.message = message;
    }

    public static <T> CommonResponse<T> success(T data) {
        return new CommonResponse<>("success", data);
    }

    public static <T> CommonResponse<T> fail(String message) {
        return new CommonResponse<>("fail", message);
    }

    // getter/setter
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
}